{% extends 'base.html' %}

{% block title %}图书列表{% endblock %}

{% block content %}
<h2>图书列表</h2>
<div class="row row-cols-1 row-cols-md-3 g-4">
    {% for book in books %}
    <div class="col">
        <div class="card h-100">
            {% if book.cover %}
            <img src="{{ book.cover.url }}" class="card-img-top book-cover" alt="{{ book.title }}">
            {% else %}
            <div class="card-img-top book-cover bg-secondary d-flex align-items-center justify-content-center">
                <span class="text-white">暂无封面</span>
            </div>
            {% endif %}
            <div class="card-body">
                <h5 class="card-title">{{ book.title }}</h5>
                <p class="card-text">
                    <strong>作者:</strong> {{ book.author }}<br>
                    <strong>出版社:</strong> {{ book.publisher }}<br>
                    <strong>状态:</strong> 
                    <span class="badge bg-{% if book.status == 'available' %}success{% elif book.status == 'borrowed' %}danger{% else %}warning{% endif %}">
                        {{ book.get_status_display }}
                    </span>
                </p>
            </div>
            <div class="card-footer">
                <a href="{% url 'books:book_detail' book.pk %}" class="btn btn-primary btn-sm">查看详情</a>
            </div>
        </div>
    </div>
    {% endfor %}
</div>
{% endblock %}